<template>
  <div>
    <!-- <h1>Welcome to the Home page!</h1> -->
    <div class="title-line">
      <div class="class-item" v-for="(item, index) in kindItems">
        <div>{{item}}</div>
      </div>
    </div>

    <div class="main">
      <div class="left-menus">
        <div class="title-item" v-for="(item, index) in titleItems">
        <div @click="clickTitle(item)">{{item.name}}</div>
      </div>
      </div>
      <iframe 
      :src="url" 
      scrolling="auto"
      frameborder="no" 
      style="width: 1500px; height: 800px" 
      />

    </div>
    <button class="logout-btn" @click="logout">Logout</button>

  </div>
</template>
 
<script>
import { mapMutations } from 'vuex'
 
export default {
  name: 'Home',
  data() {
    return {
      kindItems: ['首页', '菜鸟工具', '菜鸟笔记', '参考手册'],
      titleItems: [{'name': '个人表格', 'url': '/personInfo'}, {'name': '个人表单', 'url': '/personList'}, {'name': '个人图表', 'url': '/echartsList'}, {'name': '个人标签', 'url': '/LabelList'}, 
      {'name': '级联菜单多选联动测试', 'url': '/ElCascaderPanel'}, {'name': '级联菜单单选测试', 'url': '/ElCascader'}],
      url: '/personInfo',
    }
  },
  methods: {
    ...mapMutations(['logout']),
    logout () {
      this.$router.push('/') // 登录成功后跳转到主页
    },
    clickTitle (item) {
      console.log('clickTitle');
      console.log(item);
      this.url = item.url;
    },
  },
}
</script>

<style>
.title-line {
  display: flex;
  width: 100%;
  background-color: cyan;
}
.class-item {
  margin: 15px;
  font-size: 20px;
  cursor: pointer;
}

.class-item :hover {
  color: blue;
}

.title-item {
  margin: 20px;
  font-size: 18px;
  font-size: large;
}

.title-item :hover {
  color: red;
}

.logout-btn {
  position: fixed;
  right: 20px;
  top: 25px;
}

.main {
  display: flex;
}

.left-menus {
  margin: 10px;
  border-right: 1px solid #666666;
  width: 200px;
}
</style>  